Interactives

Column

Filtres

Column

Carte interactive

Prix Moyen

Column

Distrbution des Airbnb en foncton du Type d'habitation

Disbonibilité en nombre de jours par année

Nombre moyen de reviews

Données

Datatable

---
title: "Québec Airbnb"
author: "Boucar LY"
output:
  flexdashboard::flex_dashboard:
    theme: paper
    favicon: img/hotel.png
    source_code: embed
---

```{r setup, include=FALSE}
# prep workspace
library(dplyr)  # tidy data manipulation
library(leaflet)  # interative mapping
library(flexdashboard)  
library(DT)  # interactive tables
library(crosstalk)  # inter-widget interactivity
library(plotly)
library(summarywidget)
library(htmltools)
sch <- read.csv("D:/Promutel assurance/listings.csv")
sch <-sch[which(sch$price<9000),]
sd <- SharedData$new(sch)



valueBoxSummaryWidget <- function (value, caption = NULL, icon = NULL, color = NULL, href = NULL) 
{
    if (!is.null(color) && color %in% c("primary", "info", 
        "success", "warning", "danger")) 
        color <- paste0("bg-", color)
    valueOutput <- tags$span(class = "value-summarywidget-output", `data-caption` = caption, 
        `data-icon` = icon, `data-color` = color, 
        `data-href` = href, value)
    hasPrefix <- function(x, prefix) {
        if (!is.null(x)) 
            grepl(paste0("^", prefix), x)
        else FALSE
    }
    fontAwesome <- hasPrefix(icon, "fa")
    ionicons <- hasPrefix(icon, "ion")
    deps <- flexdashboard:::html_dependencies_fonts(fontAwesome, ionicons)
    if (length(deps) > 0) 
        valueOutput <- attachDependencies(valueOutput, deps)
    valueOutput
}
```






Interactives {data-icon="ion-stats-bars"}
=====================================  

Column {data-width=200}
-------------------------------------

### Filtres

```{r Filtres}
filter_select(
  id = "neighbourhood",
  label = "Quartier",
  sharedData = sd,
  group = ~neighbourhood
)

bscols(
  filter_checkbox(
    id = "room_type",
    label = "Type de chambre",
    sharedData = sd,
    group = ~room_type
  )
)

bscols(
  filter_slider(
    id = "price",
    label = "Prix",
    sharedData = sd,
    column = ~price,
    step = 10,
    round = TRUE,
    sep = "",
    ticks = FALSE
  )
)
bscols(
  filter_slider(
    id = "reviews_per_month",
    label = "Nombre de revues par mois",
    sharedData = sd,
    column = ~reviews_per_month,
    step = 1,
    round = TRUE,
    sep = "",
    ticks = FALSE
  )
)
```


Column {data-width=450}
-------------------------------------
    
### Carte interactive
    
```{r map}
sd %>% 
  leaflet::leaflet() %>%
  leaflet::addProviderTiles(providers$OpenStreetMap) %>% 
  leaflet::addAwesomeMarkers(
    popup = ~paste0(
      "Name: ", sch$name, "
", "Host Name: ", sch$host_name, "
", "Quartier: ", sch$neighbourhood, "
", "Prix: ", sch$price, "
", "Nombre de Reviews: ",sch$number_of_reviews, "
", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" ), # end popup() icon = awesomeIcons( library = "ion", icon = "ion-android-home" , iconColor = "white", markerColor = ifelse( test = sch$number_of_reviews >= mean(sch$number_of_reviews,na.rm = TRUE), yes = "blue", no = "green" ) ) ) %>% # end addAwesomeMarkers() leaflet::addMeasure() ``` ### Prix Moyen ```{r} valueBoxSummaryWidget( summarywidget( sd, statistic = 'mean', column = 'price', digits = 0 ) ) ``` Column {data-width=350} ------------------------------------- ### Distrbution des Airbnb en foncton du Type d'habitation ```{r } sd %>% plotly::plot_ly(y = ~room_type, type = "histogram",color =~room_type)%>% plotly::layout( yaxis=list(title="Type d'habitation"),showlegend = FALSE) ``` ### Disbonibilité en nombre de jours par année ```{r } sd %>% plotly::plot_ly(x = ~availability_365, type = "histogram",color =~room_type)%>% plotly::layout( xaxis=list(title="Nombre de jours"), legend = list(orientation = "v", xanchor = "center")) ``` ### Nombre moyen de reviews ```{r} valueBoxSummaryWidget( summarywidget( sd, statistic = 'mean', column = 'number_of_reviews', digits = 0 ), color = "yellow" ) ``` Données ===================================== ### Datatable ```{r datatable} sd %>% DT::datatable( filter = "top", # allows filtering on each column extensions = c( "Buttons" ), rownames = FALSE, # remove rownames style = "bootstrap", class = "compact", width = "100%", options = list( dom = "Blrtip", # specify content (search box, etc) deferRender = TRUE, columnDefs = list( list( visible = FALSE, targets = c(2, 3, 5:15) ) ), buttons = list( I("colvis") ) ), colnames = colnames(sch) ) ```